<template>
  <div>
    <van-nav-bar
      :title="name"
      left-text="取消"
      right-text="确认"
      left-arrow
      @click-left="changeShow"
      @click-right="myClick"
      v-if="msg !== 'Notice'"
    ></van-nav-bar>
    <component :is="msg" class="com" ref="child" @giveFlag="getFlag($event)" :head="head" :include="include" :icon="icon"></component>
  </div>
</template>

<script>
  import Birthday from "./Massage/Birthday";
  import HeadImg from "./Massage/HeadImg";
  import Nickname from "./Massage/Nickname";
  import PhoneNumber from "./Massage/PhoneNumber";
  import Sex from "./Massage/Sex";
  import Password from "./Massage/Password";
  import Notice from "./Notice";
  import {NavBar} from 'vant';

  export default {
    name: "RealMessage",
    components: {
      Birthday, HeadImg, Nickname, PhoneNumber, Sex, Notice, Password,
      [NavBar.name]: NavBar,
    },
    props: ["msg", "name", "head", "include", "icon"],
    data() {
      return {
        show: false,
        flag: false
      }
    },
    methods: {
      changeShow() {
        let _this = this;
        _this.$emit("giveMsg", false);
      },
      myClick() {
        let _this = this;
        _this.$refs.child.setMsg();
      },
      getFlag(flag) {
        let _this = this;
        if (flag !== "null") {
          _this.changeShow();
        }
      },
    }
  }
</script>

<style scoped>
  .com{
    margin-top: 20px;
  }
</style>
